package com.k12.edu.service.impl;


import com.k12.edu.dao.SchoolInfoDao;
import com.k12.edu.entity.SchoolInfo;
import com.k12.edu.service.SchoolInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学校信息表(SchoolInfo)表服务实现类
 *
 * @author makejava
 * @since 2025-08-01 11:20:14
 */
@Service("schoolInfoService")
public class SchoolInfoServiceImpl implements SchoolInfoService {
    @Resource
    private SchoolInfoDao schoolInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SchoolInfo queryById(Integer id) {
        return this.schoolInfoDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param schoolInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<SchoolInfo> queryByPage(SchoolInfo schoolInfo) {
        long total = this.schoolInfoDao.count(schoolInfo);
        return this.schoolInfoDao.queryAllByLimit(schoolInfo);
    }

    /**
     * 新增数据
     *
     * @param schoolInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SchoolInfo insert(SchoolInfo schoolInfo) {
        this.schoolInfoDao.insert(schoolInfo);
        return schoolInfo;
    }

    /**
     * 修改数据
     *
     * @param schoolInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SchoolInfo update(SchoolInfo schoolInfo) {
        this.schoolInfoDao.update(schoolInfo);
        return this.queryById(schoolInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id,String tenantId) {
        return this.schoolInfoDao.deleteById(id,tenantId) > 0;
    }
}
